<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <title>分类帖子列表</title>
</head>
<body>
<h2>分类帖子列表</h2>
<a href="${pageContext.request.contextPath}/post/publish">发布新帖子</a>
<br><br>
<form action="${pageContext.request.contextPath}/post/search" method="get" style="margin-bottom: 20px;">
    <input type="text" name="keyword" placeholder="搜索帖子..." style="padding: 8px; width: 300px;">
    <button type="submit" style="padding: 8px 15px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer;">搜索</button>
</form>
<c:forEach var="post" items="${posts}">
    <div style="border: 1px solid #ccc; padding: 10px; margin-bottom: 10px;">
        <h3>${post.title}</h3>
        <p>${post.content}</p>
        <c:if test="${post.imageUrl != null}">
            <img src="${pageContext.request.contextPath}${post.imageUrl}" alt="图片" style="max-width: 300px;">
        </c:if>
        <c:if test="${post.videoUrl != null}">
            <video controls style="max-width: 300px;">
                <source src="${post.videoUrl}" type="video/mp4">
                您的浏览器不支持视频播放。
            </video>
        </c:if>
        <br>
        <a href="${pageContext.request.contextPath}/post/detail/${post.id}">查看详情</a>
    </div>
</c:forEach>
</body>
</html>